home *** CD-ROM | disk | FTP | other *** search
- ' Billy Dennigan MBN International Systems Ltd March 1993
- ' Compuserve ID 100014,2700
- ' Makefile Generator
- ' This program generates a simple makefile by copying the MS Basic .MAK file
- ' to a file usable by the NMAKE utility, with the appropriate dependencies
- ' and switches.
- ' If you find this program useful, please acknowledge by E-Mail
- ' Example .INI files are included for VBDOS and BC7
- ' These should be changed to suit your personal configuration
- ' MM /? for help
-
- DECLARE SUB IncludeFiles (Filename$, OutFile%)
- DECLARE SUB LoadList (ListFile$, ObjList$(), NumObjs%)
- DECLARE SUB ReadIni (IniFile$, Options() AS ANY)
- DECLARE SUB ShowHelp ()
- DECLARE SUB Substitute (Change$, ObjList$())
- DECLARE FUNCTION CmdParam$ (Cmd$, name$)
- DECLARE FUNCTION GetValue$ (Num%, Ini() AS ANY)
- DECLARE FUNCTION RemoveExt$ (Filename$)
- DECLARE FUNCTION RemovePath$ (Filename$)
-
- '============== one of these per entry in the .INI file ==============
- TYPE IniRec
- Index AS INTEGER
- Value AS STRING * 50
- END TYPE
-
- CONST FALSE = 0, TRUE = NOT FALSE
- CONST NumOfSources = 128 ' max. number of sources for an EXE file
- CONST MaxIniLines = 128 ' max. number of entries in .INI file
- CONST NumSettings = 8 ' change this if you add any settings to DATA
-
- REDIM ObjList$(NumOfSources)
- REDIM Inis(MaxIniLines) AS IniRec
-
- PRINT
- PRINT " Makefile Generator. Version 2.0 Mar.1993"
- PRINT " Billy Dennigan, MBN International Systems Ltd."
- PRINT
-
- Cmd$ = COMMAND$
-
- '========== HELP FACILITY ==========
- IF INSTR(Cmd$, "/?") THEN
- CALL ShowHelp
- END
- END IF
-
- '========= get the target filename if necessary ============
- IF Cmd$ = "" THEN
- PRINT "Target File :";
- INPUT TargetFile$
- ELSE
- TargetFile$ = Cmd$
- END IF
- IF LEN(TargetFile$) = 0 THEN END
-
- '================ GET THE NAME OF THE .INI FILE ===================
- IniFile$ = "MM.INI"
- DO UNTIL LEN(DIR$(IniFile$))
- PRINT "Cannot find MM Initialisation file "; IniFile$;
- PRINT " Please enter new file spec: ";
- INPUT IniFile$
- IF LEN(IniFile$) = 0 THEN CLOSE : END
- LOOP
-
- '============ LOAD DATA INTO ARRAY OF RECORDS inis() ==============
- CALL ReadIni(IniFile$, Inis())
-
- 'truncate the extension from the target file if it was specified
- TargetFile$ = UCASE$(TargetFile$)
- TargetFile$ = RemoveExt$(TargetFile$)
-
- MakeFile$ = TargetFile$ ' Makefile to be generated
- RespFile$ = TargetFile$ + ".LNK" ' response file for linker
- ListFile$ = TargetFile$ + ".MAK" ' input list of required files
- Tab$ = CHR$(9)
-
- '--- load in the list of Modules -----
- CALL LoadList(ListFile$, ObjList$(), NumObjs%)
-
- MkeFile% = FREEFILE
- OPEN MakeFile$ FOR OUTPUT AS #MkeFile% ' MakeFile
- LnkFile% = FREEFILE
- OPEN RespFile$ FOR OUTPUT AS #LnkFile% ' Response file
- mmddyy$ = DATE$
- ddmmyy$ = MID$(DATE$, 4, 2) + "/" + LEFT$(DATE$, 2) + "/" + RIGHT$(DATE$, 2)
-
- PRINT #MkeFile%, "# Makefile for "; TargetFile$
- PRINT #MkeFile%, "# Date written: "; ddmmyy$; " at "; LEFT$(TIME$, 5);
- PRINT #MkeFile%, " by Makefile Generator [MM] Version 1.10"
- PRINT #MkeFile%, "# .INI file used was "; IniFile$
- PRINT #MkeFile%, "# Billy Dennigan, MBN International Systems Ltd."
- PRINT #MkeFile%, "# Uses response file "; RespFile$; " for Linker"
- PRINT #MkeFile%, "#"
-
- '------ compiler is Setting 1 -----
- DO
- Tmp$ = GetValue$(1, Inis())
- TmpLen% = LEN(Tmp$)
- IF TmpLen% THEN Compiler$ = Tmp$
- LOOP WHILE TmpLen%
-
- '------ linker is Setting 2 ------
- DO
- Tmp$ = GetValue$(2, Inis())
- TmpLen% = LEN(Tmp$)
- IF TmpLen% THEN Linker$ = Tmp$
- LOOP WHILE TmpLen%
-
- '--------- extract all the compiler flags (Setting 3) ---------
- DO
- ThisFlag$ = GetValue$(3, Inis())
- CompFlag$ = CompFlag$ + ThisFlag$
- LOOP WHILE LEN(ThisFlag$)
-
- '--------- extract all the linker flags (Setting 4) -----------
- DO
- ThisFlag$ = GetValue$(4, Inis())
- LinkFlag$ = LinkFlag$ + ThisFlag$
- LOOP WHILE LEN(ThisFlag$)
-
- '--------- get filename substitutions (Setting 6) ------------
- DO
- Change$ = GetValue$(6, Inis())
- IF LEN(Change$) = 0 THEN EXIT DO
- CALL Substitute(Change$, ObjList$())
- LOOP
-
-
- '------ INCLUDEs is Setting 7 ------
- 'At this point, just determine whether or not the user wants INCLUDED files
- ' put into the dependencies list. Will process them later on.
- DO
- Tmp$ = GetValue$(7, Inis())
- TmpLen% = LEN(Tmp$)
- IF TmpLen% THEN GetIncludes$ = UCASE$(Tmp$)
- LOOP WHILE TmpLen%
- IF INSTR(GetIncludes$, "TRUE") THEN GetIncludes% = -1
-
-
- '------ ObjDir is Setting 8 ------
- ' this can be used to specify a directory where all .OBJ files are to be put
- DO
- Tmp$ = GetValue$(8, Inis())
- TmpLen% = LEN(Tmp$)
- IF TmpLen% THEN
- ObjDir$ = UCASE$(Tmp$)
- ObjDir% = TRUE
- END IF
- LOOP WHILE TmpLen%
-
- '----- format the path so that it can be used to make up a valid filename
- LastChar$ = RIGHT$(ObjDir$, 1)
- IF LastChar$ <> ":" AND LastChar$ <> "\" THEN ObjDir$ = ObjDir$ + "\"
-
-
-
- PRINT #MkeFile%, "# Can change your source file and compilers,etc here:"
- PRINT #MkeFile%, ""
- PRINT #MkeFile%, "EXE = "; TargetFile$
- PRINT #MkeFile%, "COMPILE = "; Compiler$
- PRINT #MkeFile%, "LINK = "; Linker$
- PRINT #MkeFile%, "COMPFLAGS = "; CompFlag$
- PRINT #MkeFile%, "LINKFLAGS = "; LinkFlag$
- PRINT #MkeFile%,
- PRINT #MkeFile%, "ALL : $(EXE).EXE"
-
- '=========== DEPENDENCIES FOR THE .OBJ FILE (COMPILATION PHASE) ===========
- FOR i% = 1 TO NumObjs%
- Filename$ = ObjList$(i%)
- Stem$ = RemoveExt$(Filename$)
-
- '---------- If a path was specified for the .OBJ files ---------
- IF ObjDir% THEN Stem$ = ObjDir$ + RemovePath$(Stem$)
-
- PRINT Filename$;
- PRINT #MkeFile%, ""
- PRINT #MkeFile%, Stem$; ".OBJ : ";
- PRINT #MkeFile%, Filename$;
- IF GetIncludes% THEN
- '------ Find which files have been INCLUDEd in this one ------
- Col% = POS(0): Row% = CSRLIN
- COLOR 15
- PRINT " Scanning...";
- COLOR 7
- CALL IncludeFiles(Filename$, MkeFile%)
- LOCATE Row%, Col%: PRINT " ";
- LOCATE Row%, Col%
- END IF
- PRINT
-
- PRINT #MkeFile%,
- PRINT #MkeFile%, Tab$; "$(COMPILE) $(COMPFLAGS) "; Filename$; " "; Stem$; ".OBJ ;"
-
- NEXT i%
-
-
- '========== DEPENDENCIES FOR THE .EXE FILE i.e. THE LINK PHASE =============
- PRINT #MkeFile%, ""
- PRINT #MkeFile%, "$(EXE).EXE : ";
- FOR i% = 1 TO NumObjs%
- ObjFile$ = RemoveExt$(ObjList$(i%)) + ".OBJ "
-
- IF ObjDir% THEN ObjFile$ = ObjDir$ + RemovePath$(ObjFile$)
-
- PRINT #MkeFile%, ObjFile$; " ";
- NEXT i%
-
- '=============== THE .EXE IS ALSO DEPENDENT ON .LIB FILES ==================
- Lib$ = GetValue$(0, Inis()) ' reset internal pointers
- DO
- Lib$ = GetValue$(5, Inis())
- IF LEN(Lib$) THEN PRINT #MkeFile%, UCASE$(Lib$); " "; ELSE EXIT DO
- LOOP
-
- PRINT #MkeFile%, ""
-
- PRINT #MkeFile%, Tab$; "$(LINK) $(LINKFLAGS) ";
- PRINT #MkeFile%, "@"; RespFile$
-
-
- '=============== GENERATE THE LINKER RESPONSE FILE ===================
- '--------------- DEAL WITH ALL NECESSARY .OBJ FILES ------------------
- FOR i% = 1 TO NumObjs%
- ObjFile$ = RemoveExt$(ObjList$(i%)) + ".OBJ "
-
- '--- temporary: leave the OBJ files in current dir ----
- IF ObjDir% THEN ObjFile$ = ObjDir$ + RemovePath$(ObjFile$)
-
- PRINT #LnkFile%, ObjFile$; " +"
- NEXT i%
- '--------------- TERMINATE THE LIST OF .OBJ FILES ---------------------
- PRINT #LnkFile%,
-
- '--------------- SPECIFY THE NAME OF THE .EXE FILE --------------------
- PRINT #LnkFile%, TargetFile$; ".EXE"
-
- '--------------- SPECIFY THE NAME OF THE .MAP FILE --------------------
- PRINT #LnkFile%, "NUL.MAP"
-
- '--------------- GENERATE THE LIST OF LIBRARY FILES -------------------
- Lib$ = GetValue$(0, Inis()) ' reset internal pointers
- DO
- PRINT "Libraries : ";
- Lib$ = GetValue$(5, Inis())
-
- 'when "LIB=;" is encountered, no more libraries are included.
- SemiColon% = INSTR(Lib$, ";")
- IF SemiColon% THEN
- Lib$ = LEFT$(Lib$, SemiColon%)
- IF Lib$ = ";" THEN PRINT : EXIT DO
- END IF
-
- IF LEN(Lib$) = 0 THEN ' if the .INI file has no more libs,
- INPUT "", Lib$ ' then get one from the user
- ELSE
- PRINT Lib$; "+" ' this is the lib read from the .INI file
- END IF
- IF LEN(Lib$) = 0 THEN EXIT DO
-
- PRINT #LnkFile%, UCASE$(Lib$); "+"
- LOOP
-
- '--------------- TERMINATE THE LIST OF .LIB FILES ---------------------
- PRINT #LnkFile%, ""
-
- '----------- SPECIFY THE NAME OF THE DEFINITIONS FILE -----------------
- PRINT #LnkFile%, "NUL.DEF ;"
-
- PRINT #LnkFile%,
-
- CLOSE #MkeFile%, #LnkFile%
-
- PRINT "Makefile has been generated."
- PRINT "Type NMAKE "; MakeFile$; " to begin compilation."
- END
-
- '--- these are the names of settings which can be set in the .INI file
- '**** change 'CONST NumSettings' if you add or delete any of these. ****
- SettingNames:
- DATA 1,Compile, 2,Link, 3,CompFlags
- DATA 4,LinkFlags, 5,Lib, 6,Replace
- DATA 7,CheckIncludes, 8,ObjDir
-
- ' Billy Dennigan 2-Sep-1992
- ' Function to derive a qualifier from a string such as COMMAND$
- ' Eg: input CmdParam$("/B /X=12", "X=") will return "12"
- ' Case insensitive.
- FUNCTION CmdParam$ (Cmd$, Ident$)
-
- First% = INSTR(UCASE$(Cmd$), UCASE$(Ident$))
- IF First% THEN
- First% = First% + LEN(Ident$)
- Last% = First% - 1
-
- 'First% points to the first letter of the string
- 'now step forward until the end is reached
- 'the string is separated by either a / or a space
- DO
- Last% = Last% + 1
- Ch$ = MID$(Cmd$, Last%, 1)
- LOOP UNTIL Ch$ = " " OR Ch$ = "/" OR Last% > LEN(Cmd$)
-
- CmdParam$ = RTRIM$(MID$(Cmd$, First%, Last% - First%))
- ELSE
- CmdParam$ = ""
- END IF
-
- END FUNCTION
-
- ' Num% identifies the type of value you're looking for
- 'Eg: Lib=, Compiler=,... etc
- '
- FUNCTION GetValue$ (Num%, Ini() AS IniRec)
- STATIC LastNum%, CurrentItem%
-
- '---- reset the pointer ---
- IF Num% = 0 THEN
- LastNum% = 0
- EXIT FUNCTION
- END IF
-
- ' If we're now looking for a different attribute, go back to the start
- ' of the list, otherwise continue searching from where we left off the
- ' last time.
- IF Num% <> LastNum% THEN CurrentItem% = 1
-
- DO UNTIL CurrentItem% > MaxIniLines
- CurrentNum% = Ini(CurrentItem%).Index
- CurrentItem% = CurrentItem% + 1
- IF CurrentNum% = Num% THEN
- Value$ = Ini(CurrentItem% - 1).Value
- EXIT DO
- END IF
- LOOP
- LastNum% = Num%
-
- '---------------------------------------------------------------------------
- ' if a line of the form 'Value=$(var)' is found, the environment is searched
- ' for 'var=NewVar'. This is the same as having 'Value=NewVar' in the .INI
- ' file.
- Macro% = INSTR(Value$, "$(")
- IF Macro% THEN
- Macro$ = MID$(Value$, Macro% + 2)
- RBracket% = INSTR(Macro$, ")")
- IF RBracket% = 0 THEN RBracket% = LEN(Macro$) + 1
- Macro$ = UCASE$(LEFT$(Macro$, RBracket% - 1))
- EnvValue$ = ENVIRON$(Macro$)
- IF LEN(EnvValue$) THEN Value$ = EnvValue$
- END IF
-
- GetValue$ = LTRIM$(RTRIM$(Value$))
- END FUNCTION
-
- ' called from Main program
- ' 'Filename$' is opened and searched for the work '$include, and all its
- ' filespecs are printed to OutFile%
- '
- SUB IncludeFiles (Filename$, OutFile%)
- OpenInc$ = "$INCLUDE: '"
- CloseInc$ = "'"
- LenInc% = LEN(OpenInc$)
-
- IF LEN(DIR$(Filename$)) = 0 THEN EXIT SUB
- Infile% = FREEFILE
- OPEN Filename$ FOR INPUT SHARED AS #Infile%
- DO WHILE NOT EOF(Infile%)
- LINE INPUT #Infile%, Current$
- Current$ = UCASE$(LTRIM$(RTRIM$(Current$)))
- '--- if it has an INCLUDE statement ---
- StartInc% = INSTR(Current$, OpenInc$)
- IF (StartInc% > 0) AND (StartInc% < 6) THEN
- EndInc% = INSTR(StartInc% + LenInc%, Current$, CloseInc$)
- IF EndInc% = 0 THEN EXIT DO
- FileSpec$ = MID$(Current$, StartInc% + LenInc%, EndInc% - LenInc% - StartInc%)
- PRINT #OutFile%, " "; FileSpec$; " ";
- END IF
- LOOP
-
- CLOSE #Infile%
- END SUB
-
- 'CALLED FROM: Main Program
- '------ load in the list of required files from the .MAK file --------
- SUB LoadList (ListFile$, ObjList$(), NumObjs%)
-
- IF LEN(DIR$(ListFile$)) THEN
- LstFile% = FREEFILE
- OPEN ListFile$ FOR INPUT AS #LstFile%
- DO UNTIL EOF(LstFile%)
- LINE INPUT #LstFile%, Line$
- Line$ = UCASE$(Line$)
- IF (LEN(Line$) = 0) THEN
- EXIT DO
- END IF
- NumObjs% = NumObjs% + 1
- ObjList$(NumObjs%) = Line$
- LOOP
- CLOSE #LstFile%
- ELSE
- ' there is no .MAK file, just a single source file
- NumObjs% = 1
- ObjList$(NumObjs%) = RemoveExt$(ListFile$) + ".BAS"
- END IF
-
- END SUB
-
- 'read the settings from the .INI file
- '
- SUB ReadIni (IniFile$, Ini() AS IniRec)
-
- DIM Setting$(NumSettings), SettingNum%(NumSettings)
- RESTORE SettingNames
- FOR i% = 1 TO NumSettings: READ SettingNum%(i%), Setting$(i%): NEXT i%
- NumLines% = 0
-
- IniFile% = FREEFILE
- OPEN IniFile$ FOR INPUT SHARED AS #IniFile%
- DO WHILE NOT EOF(IniFile%)
- LINE INPUT #IniFile%, IniLine$
- IniLine$ = LTRIM$(RTRIM$(IniLine$))
- DO ' just once
- ' ignore everything to t'right of a '#'
- Hash% = INSTR(IniLine$, "#")
- IF Hash% THEN
- IniLine$ = LEFT$(IniLine$, Hash% - 1)
- END IF
-
- Centre% = INSTR(IniLine$, "=") 'Eg: "LIB=C:\bc7\lib\im2.lib"
- IF Centre% <= 1 THEN EXIT DO
- Lhs$ = LCASE$(LEFT$(IniLine$, Centre% - 1))
- Lhs$ = LTRIM$(RTRIM$(Lhs$)) 'Eg: "LIB"
- Rhs$ = MID$(IniLine$, Centre% + 1)
- Rhs$ = LTRIM$(RTRIM$(Rhs$)) 'Eg: "C:\bc7\lib\im2.lib"
- ' now find the setting which matches the L.H.S and assign it the value of
- ' the R.H.S.
- Match% = 0
- FOR i% = 1 TO NumSettings
- IF LCASE$(Setting$(i%)) = Lhs$ THEN
- Match% = SettingNum%(i%)
- EXIT FOR
- END IF
- NEXT i% ' Eg: Match% = 5
- '--- match% is now an index for which setting to assign this RHS value
- IF Match% THEN
- NumLines% = NumLines% + 1
- Ini(NumLines%).Index = Match% ' Eg: 5
- Ini(NumLines%).Value = Rhs$ ' Eg: "C:\bc7\lib\im2.lib"
- END IF
- LOOP UNTIL TRUE
- LOOP
- CLOSE #IniFile%
-
- END SUB
-
- ' Billy Dennigan 17-Jul-1992
- ' Function to strip the '.EXT' off a filename
- ' Eg: Input: "MENU.C"
- ' Output: "MENU"
- FUNCTION RemoveExt$ (Filename$)
-
- 'step from Right to Left to avoid dots occurring in the path spec.
- TmpName$ = Filename$
- FOR Dot% = LEN(TmpName$) TO 1 STEP -1
- Ch$ = MID$(TmpName$, Dot%, 1)
- IF Ch$ = "." THEN EXIT FOR
- IF Ch$ = "\" THEN Dot% = 0
- NEXT Dot%
-
- IF Dot% > 0 THEN
- TmpName$ = LEFT$(Filename$, Dot% - 1)
- END IF
- RemoveExt$ = TmpName$
-
- END FUNCTION
-
- 'Remove the path from a filename
- ' Eg: Input: "\PATH\MENU.C"
- ' Output: "MENU.C"
- FUNCTION RemovePath$ (Filename$)
-
- 'step from Right to Left to avoid dots occurring in the path spec.
- TmpName$ = Filename$
-
- FOR Slash% = LEN(TmpName$) TO 1 STEP -1
- Ch$ = MID$(TmpName$, Slash%, 1)
- IF Ch$ = "\" THEN EXIT FOR
- NEXT Slash%
-
- IF Slash% > 0 THEN
- TmpName$ = MID$(Filename$, Slash% + 1)
- END IF
- RemovePath$ = LTRIM$(RTRIM$(TmpName$))
-
-
- END FUNCTION
-
- '
- '
- SUB ShowHelp ()
-
- PRINT "USAGE: MM [filespec]"
- PRINT " <filespec> contains a list of files used to make a target file."
- PRINT
- PRINT " Configuration file MM.INI should be in the current directory, if it"
- PRINT " is not, MM will prompt for the name of a configuration file."
- PRINT
- PRINT "Settings for the configuration file:"
- PRINT
- PRINT " Compile = <filespec> specifies your compiler."
- PRINT
- PRINT " Link = <filespec> specifies your linker."
- PRINT
- PRINT " Lib = <filespec>[;] specifies a library file. There can be as many"
- PRINT " Lib statements as you wish."
- PRINT " A semi-colon terminates the list of library"
- PRINT " specifications, otherwise MM will prompt the"
- PRINT " user for extra libraries."
- PRINT
- GOSUB HoldIt
- PRINT
- PRINT
- PRINT " ObjDir = <dirspec> This may be used to specify a directory where all"
- PRINT " object files are to be placed."
- PRINT
- PRINT " CompFlags = <expression> specifies switches used by the compiler."
- PRINT
- PRINT " LinkFlags = <expression> specifies switches used by the linker."
- PRINT
- PRINT " Replace = OldString//NewString "
- PRINT " All occurrances of 'OldString' in filenames are"
- PRINT " replaced with 'NewString'. Use this for subtituting"
- PRINT " paths or filename extensions."
- PRINT
- PRINT " Replace = OldString/NewString1[,NewString2[NewStringn[,... "
- PRINT " Occurrances of 'OldString' in filenames are"
- PRINT " replaced with 'NewString1'. If the resulting"
- PRINT " file is present, this will be written to the"
- PRINT " Makefile, otherwise 'NewString2' will be tried,"
- PRINT " and so until until a file is found."
- PRINT
- PRINT
- GOSUB HoldIt
- PRINT
- PRINT " CheckIncludes = True|False If this is set to True, each source file"
- PRINT " is checked for INCLUDEd files, and any found"
- PRINT " are put in the dependencies list."
- PRINT
- PRINT " Expressions of the form X=$(Y) cause the environment to be searched."
- PRINT " For example Lib = $(LIBDIR) causes the environment to be searched for"
- PRINT " an entry LIBDIR="
- PRINT " So, if in you environment settings you have LIBDIR=C:\VBDOS\LIB ,this"
- PRINT " is the same as having the line LIB=C:\VBDOS\LIB in the "
- PRINT " MM.INI file."
- PRINT
- EXIT SUB
-
- '------------- Pause after filling a screen --------
- HoldIt:
- COLOR 15, 0
- PRINT " Press any key to continue...."
- COLOR 7, 0
- DO: LOOP UNTIL LEN(INKEY$)
-
- RETURN
-
- END SUB
-
- ' Want to replace .STB files with either .FRM or .BAS ,
- ' only one of the two is present.
- ' change$ is of the form OLD/NEW1,NEW2,...,NEWn
- ' NEW1 is searched for, if it is found then it is used to replace OLD, if
- ' not, NEW2 is searched for, then NEW3, .....
- ' If Change$ is of the form OLD//NEW (i.e. Two slashes), the replacement
- ' is performed regardless of whether the NEW file is found.
- ' Eg: xxxOLDyy would be replaced by xxxNEWyy
- ' ( The purpose of this is to automatically reinstate stub files in the
- ' environment when building an EXE file.)
- '
- SUB Substitute (Change$, ObjList$())
-
- Slash% = INSTR(Change$, "/")
- IF Slash% <= 1 THEN EXIT SUB
-
- OldStr$ = UCASE$(LEFT$(Change$, Slash% - 1))
- OldLen% = LEN(OldStr$)
- Rhs$ = UCASE$(MID$(Change$, Slash% + 1))
-
- '--- check for a second slash, if one is there then we ---
- '--- don't care whether the substitute file is present. ---
- IF LEFT$(Rhs$, 1) = "/" THEN
- DontCare% = TRUE
- Rhs$ = MID$(Rhs$, 2)
- END IF
-
- FOR i% = 1 TO NumOfSources
- OldPos% = 0
- LeftComma% = 1
- RightComma% = 2
- DO ' once per substitute on the RHS until a valid substitute is found
- CurrentFile$ = ObjList$(i%)
- OldPos% = INSTR(CurrentFile$, OldStr$)
- IF OldPos% = 0 THEN EXIT DO
-
- RightComma% = INSTR(LeftComma%, Rhs$, ",")
- IF RightComma% = 0 THEN RightComma% = LEN(Rhs$) + 1
- NewLen% = RightComma% - LeftComma% ' length of one NEW string
- IF NewLen% <= 0 THEN EXIT DO
- NewStr$ = MID$(Rhs$, LeftComma%, NewLen%)
- LeftComma% = RightComma% + 1
-
- ' construct the new line from parts of its old self and the new string
- CurrentFile$ = LEFT$(CurrentFile$, OldPos% - 1) + NewStr$ + MID$(CurrentFile$, OldPos% + OldLen%)
-
- 'if the replace file exists, put it into the makefile
- IF LEN(DIR$(CurrentFile$)) OR DontCare% THEN
- PRINT " Replacing "; ObjList$(i%), " with : "; CurrentFile$
- ObjList$(i%) = CurrentFile$
- EXIT DO
- END IF ' len(dir$(CurrentFile$))...
- LOOP
- NEXT i%
-
- END SUB
-
-